package com.ywxx.dyhelper.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.ywxx.dyhelper.R;
import com.ywxx.dyhelper.base.BaseAcitivity;
import com.ywxx.dyhelper.model.TaskConfig;
import com.ywxx.dyhelper.utils.ConstValues;
import com.ywxx.dyhelper.widget.NumberAddSubView;

import androidx.appcompat.app.AppCompatActivity;

/**
 * 抖音养号
 */
public class KeepNoSettingAcitivity extends BaseAcitivity
{

    private NumberAddSubView labNum;
    private NumberAddSubView labOperNum;
    private LinearLayout llStart;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_keep_no_setting_acitivity);

        InitUI();
        DataToUI();
    }

    @Override
    protected void InitUI()
    {
        InitTitle();

        labNum = findViewById(R.id.labNum);
        labOperNum = findViewById(R.id.labOperNum);
        llStart = findViewById(R.id.llStart);

        labNum.setMaxValue(8);
        labNum.setMinValue(1);

        labOperNum.setMaxValue(50);
        labOperNum.setMinValue(5);

        llStart.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                appconfig = new TaskConfig();
                appconfig.runtime = labNum.getValue();
                appconfig.oprtime = labOperNum.getValue();

                ConstValues.SaveValue(KeepNoSettingAcitivity.this, "runtime" + TaskType, labNum.getValue());
                ConstValues.SaveValue(KeepNoSettingAcitivity.this, "opertime" + TaskType, labOperNum.getValue());
                StartTaskServer(TaskType);
            }
        });
    }

    @Override
    protected void DataToUI()
    {
        int runtime = ConstValues.getIntValue(this, "runtime" + TaskType, 4);
        int opertime = ConstValues.getIntValue(this, "opertime" + TaskType, 8);
        labNum.setValue(runtime);
        labOperNum.setValue(opertime);
    }
}